package com.chinasofti.shoot;

        import java.awt.image.BufferedImage;

//飞行物
public abstract class FlyingObject {
    protected BufferedImage imge;//图片
    protected int width;
    protected int height;
    protected int x;//坐标
    protected int y;//坐标
    //飞行物
    public abstract void step();
    //判断飞行物是否越界
    public abstract boolean outOfBounds();
    //敌人被子弹射击

    public  boolean shootBy(Bullet bullet){
        int x1=this.x;//x1敌机的x
        int x2 = this.x+this.width;//x2敌机的x+敌人的宽
        int y1=this.y;//y1敌机的y
        int y2 = this.y+this.height;//y2敌人的y+敌机高
        int x = bullet.x;//x子弹的x
        int y =bullet.y;//y子弹的y
        return  x>x1
                &&
                x<x2
                &&
                y>y1
                &&
                y<y2;
    }

}
